<?php


namespace app\system\logic;

class LoginLogic
{
	public static function login($post)
	{
		$admin_info = \think\Db::name("system_admin")->field(["id", "account", "password", "token", "name", "role_id"])->where(["account" => $post["account"]])->find();
		$ip = request()->ip();
		$time = time();
		$token = GenerateToken(["id" => $admin_info["id"], "startTime" => time(), "ip" => $ip]);
		\think\Db::name("system_admin")->where(["id" => $admin_info["id"]])->update(["login_ip" => $ip, "login_time" => $time, "token" => $token]);
		$admin_info["token"] = $token;
		return ["id" => $admin_info["id"], "token" => $token];
	}
	public static function logout($admin_id)
	{
		if ($admin_id) {
		}
		session(null);
	}
}